package com.zhongkai.service.config;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhongkai.dao.config.DepartmentDAO;
import com.zhongkai.model.config.Department;
import com.zhongkai.service.BaseService;

@Component
@Transactional
public class DepartmentService extends BaseService {

	private static DepartmentDAO departmentDAO;
	
	
	
	public DepartmentDAO getDepartmentDAO() {
		return departmentDAO;
	}

	@Resource
	public void setDepartmentDAO(DepartmentDAO departmentDAO) {
		this.departmentDAO = departmentDAO;
	}


	/*查找所有*/
	public List findAll() throws Exception {
		return departmentDAO.findAll();
	}
	
	
	public void save(Department department) throws Exception{
		departmentDAO.save(department);
	}

	public void delete(Department department) throws Exception {
		departmentDAO.delete(department);
	}

	public Department findById(java.lang.Integer id) throws Exception {
		
		return departmentDAO.findById(id);
	}

	public List findByExample(Department department) throws Exception {
		
		return departmentDAO.findByExample(department);
	}

	public List findByProperty(String propertyName, Object value) throws Exception {
		
		return departmentDAO.findByProperty(propertyName, value);
	}
	public Department merge(Department department) throws Exception {
		
		return departmentDAO.merge(department);
	}

	public void attachDirty(Department department) throws Exception {
		departmentDAO.attachDirty(department);
	}

	public void attachClean(Department department) throws Exception {
		departmentDAO.attachClean(department);
	}

	public static DepartmentDAO getFromApplicationContext(ApplicationContext ctx) {
		return departmentDAO.getFromApplicationContext(ctx);
	}
	
	/**
	 *  根据属性组查找
	 * @param hql
	 * @param values
	 * @return
	 * @throws Exception
	 */	 
		public List findByHql(String hql, Object[] values) throws Exception {
			return departmentDAO.findByHql(hql, values);
		}
	
}
